package com.j2eefast.flowable.erp.service;


import com.j2eefast.flowable.erp.entity.bpmErpPersonDeptpettycashEntity;
import com.j2eefast.flowable.erp.mapper.bpmErpPersonDeptpettycashMapper;
import com.j2eefast.common.core.mutidatasource.annotaion.DataSource;
import com.j2eefast.common.core.page.Query;
import com.j2eefast.common.core.utils.PageUtil;
import com.j2eefast.common.core.utils.ToolUtil;
import com.j2eefast.framework.utils.Constant;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import javax.annotation.Resource;
import org.springframework.transaction.annotation.Transactional;
import java.util.Map;
import java.util.Arrays;
/**
 *
 * ERP人事部门备用金申请Service接口
 * @author: yhli
 * @date 2020-07-22 14:20
 */
@Service
public class bpmErpPersonDeptpettycashService extends ServiceImpl<bpmErpPersonDeptpettycashMapper,bpmErpPersonDeptpettycashEntity> {

	@Resource
	private bpmErpPersonDeptpettycashMapper bpmErpPersonDeptpettycashMapper;

	/**
	 * mybaitis-plus 页面分页查询
     */
    @DataSource(name="FLOWABLE")
	public PageUtil findPage(Map<String, Object> params) {
        QueryWrapper<bpmErpPersonDeptpettycashEntity> queryWrapper = new QueryWrapper<bpmErpPersonDeptpettycashEntity>();
           String serialNumber = (String) params.get("serialNumber");
         queryWrapper.eq(ToolUtil.isNotEmpty(serialNumber), "serial_number", serialNumber);
                               String moneyReason = (String) params.get("moneyReason");
         queryWrapper.eq(ToolUtil.isNotEmpty(moneyReason), "money_reason", moneyReason);
          String moneyMoney = (String) params.get("moneyMoney");
         queryWrapper.eq(ToolUtil.isNotEmpty(moneyMoney), "money_money", moneyMoney);
                String moneyRepaymentMethod = (String) params.get("moneyRepaymentMethod");
         queryWrapper.eq(ToolUtil.isNotEmpty(moneyRepaymentMethod), "money_repayment_method", moneyRepaymentMethod);
          String moneyRepaymentTerm = (String) params.get("moneyRepaymentTerm");
         queryWrapper.eq(ToolUtil.isNotEmpty(moneyRepaymentTerm), "money_repayment_term", moneyRepaymentTerm);
             String accountingPersonname = (String) params.get("accountingPersonname");
        queryWrapper.like(ToolUtil.isNotEmpty(accountingPersonname), "accounting_personname", accountingPersonname);
                                                                            String cashierDate = (String) params.get("cashierDate");
         queryWrapper.eq(ToolUtil.isNotEmpty(cashierDate), "cashier_date", cashierDate);
                 		Page<bpmErpPersonDeptpettycashEntity> page = bpmErpPersonDeptpettycashMapper.selectPage(new Query<bpmErpPersonDeptpettycashEntity>(params).getPage(), queryWrapper);
		return new PageUtil(page);
    }

    /**
     * 自定义分页查询，含关联实体对像
     */
    @DataSource(name="FLOWABLE")
	public PageUtil findPage(Map<String, Object> params,bpmErpPersonDeptpettycashEntity bpmErpPersonDeptpettycashEntity) {
		Page<bpmErpPersonDeptpettycashEntity> page = bpmErpPersonDeptpettycashMapper.findPage(new Query<bpmErpPersonDeptpettycashEntity>(params).getPage(), bpmErpPersonDeptpettycashEntity,(String) params.get(Constant.SQL_FILTER))  ;
		return new PageUtil(page);
	}
	/**
     * 批量删除
     */
    @DataSource(name="FLOWABLE")
	@Transactional(rollbackFor = Exception.class)
	public boolean deletebpmErpPersonDeptpettycashByIds(String[] ids) {
		return removeByIds(Arrays.asList(ids));
	}

	/**
     * 单个删除
     */
    @DataSource(name="FLOWABLE")
	public boolean deletebpmErpPersonDeptpettycashById(String id) {
		return removeById(id);
	}

	/**
     * 保存
     */
    @DataSource(name="FLOWABLE")
	public boolean savebpmErpPersonDeptpettycash(bpmErpPersonDeptpettycashEntity bpmErpPersonDeptpettycash){
        return save(bpmErpPersonDeptpettycash);
    }

	/**
     * 修改根居ID
     */
    @DataSource(name="FLOWABLE")
	public boolean updatebpmErpPersonDeptpettycashById(bpmErpPersonDeptpettycashEntity bpmErpPersonDeptpettycash) {
		return updateById(bpmErpPersonDeptpettycash);
	}

	/**
     * 根居ID获取对象
     */
    @DataSource(name="FLOWABLE")
	public bpmErpPersonDeptpettycashEntity getbpmErpPersonDeptpettycashById(String id){
		return getById(id);
	}
}
